// 
// Decompiled by Procyon v0.5.36
// 

package com.orange.boot.dev5.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.io.Serializable;
import com.orange.boot.utils.R;
import org.springframework.stereotype.Service;
import com.orange.boot.dev5.service.AdministratorService;
import com.orange.boot.dev5.entity.User;
import com.orange.boot.dev5.mapper.AdministratorMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

@Service
public class AdministratorServiceImpl extends ServiceImpl<AdministratorMapper, User> implements AdministratorService {
    public AdministratorServiceImpl() {
    }

    public R updatePermissions(User user, Integer oldStatus) {
        if (oldStatus == 2) {
            return R.error().message("不可以修改管理员权限");
        } else {
            int i = ((AdministratorMapper)this.baseMapper).updateById(user);
            return i > 0 ? R.ok() : R.error();
        }
    }

    public R getUser(String id) {
        User user = (User)((AdministratorMapper)this.baseMapper).selectById(id);
        return R.ok().data("uesr", user);
    }

    public R removeUser(String id) {
        int i = ((AdministratorMapper)this.baseMapper).deleteById(id);
        return i > 0 ? R.ok() : R.error();
    }

    public R checkUser(String id) {
        User user = new User();
        user.setId(id);
        user.setPass(1);
        int i = ((AdministratorMapper)this.baseMapper).updateById(user);
        return i > 0 ? R.ok() : R.error();
    }

    public R getNotPassUser() {
        QueryWrapper<User> wrapper = new QueryWrapper();
        wrapper.eq("pass", 0);
        List<User> users = ((AdministratorMapper)this.baseMapper).selectList(wrapper);
        return R.ok().data("users", users);
    }
}
